﻿using MediatR;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using S.Authorization.API.Application.Command.RoleMenuCommand;
using S.Authorization.Domain.Model.Authority;
using S.Authorization.Infrastructure;
using S.Authorization.Infrastructure.Interface.Menu;
using S.Authorization.Infrastructure.Interface.RoleMenu;

namespace S.Authorization.API.Application.CommandHandlers.RoleMenuCommandHandler
{
    /// <summary>
    /// 删除角色菜单功能表
    /// 根据菜单Id和角色ID
    /// </summary>
    public class FeatureMenuRoleDeleteRangeCommandHandler : IRequestHandler<FeatureMenuRoleDeleteRangeCommand, bool>
    {
        #region 注入
        private readonly IRoleMenuRepository repository;
        private readonly DbHelper dbHelper;
        public FeatureMenuRoleDeleteRangeCommandHandler(IRoleMenuRepository repository,IMenuRepository _menuRepository,DbHelper _dbHelper, IMenuListCountRepository _menuListCountRepository)
        {
            this.repository = repository;
            this.dbHelper = _dbHelper;
            
        }
        #endregion
        public async Task<bool> Handle(FeatureMenuRoleDeleteRangeCommand request, CancellationToken cancellationToken)
        {
            return await repository.DeleteRangeFeatureMenuRole(request.MenuId,request.RoleId);
        }
        
    }
}
